/*
day331 
2020.7.24 
*/
#include<iostream>
#include<cstdlib>
#include<vector>
using namespace std;

class Solution {
public:
    int countServers(vector<vector<int>>& grid) {
    	int size_raw=grid.size();
    	int size_col=grid.front().size();
    	
		int *raw=new int[size_raw];
		int *col=new int[size_col];
	
		for(int i=0;i<size_raw;++i)
		{
			raw[i]=0;
		}
		
		for(int i=0;i<size_col;++i)
		{
			col[i]=0;
		}
		
		for(int i=0;i<size_raw;++i)
		{
			for(int j=0;j<size_col;++j)
			{
				if(grid[i][j]==1)
				{
					raw[i]++;
					col[j]++;
				}
			}
		}

		int res=0;
		for(int i=0;i<size_raw;++i)
		{
			for(int j=0;j<size_col;++j)
			{
				if(grid[i][j]==1 && (raw[i]>1 || col[j]>1))
				{
					res++;
				}
			}
		}
		
		return res;
    }
};

int main()
{
	vector<vector<int>> grid = {{1,0},{0,1}};
	Solution s;
	int res=s.countServers(grid);
	cout<<res;
	return 0;
}
